CreakingHeartState tag and mechanism#2783
Conversation
| // --> | ||
| tagProcessor.registerTag(ElementTag.class, "heart_state", (attribute, object) -> { | ||
| if (!(object.getBlockState().getBlockData() instanceof CreakingHeart heart)) { | ||
| Debug.echoError("The 'LocationTag.heart_state' tag can only be called on a creaking heart block."); |
| Debug.echoError("The 'LocationTag.heart_state' tag can only be called on a creaking heart block."); | ||
| return null; | ||
| } | ||
| return Utilities.enumlikeToElement(heart.getCreakingHeartState()); |
There was a problem hiding this comment.
Can probably just be new ElementTag(state)? These methods do some extra stuff for legacy/cross-version compatibility, but aren't really needed for normal enum usage.
| }); | ||
|
|
||
| // <--[mechanism] | ||
| // @object LocationTag |
There was a problem hiding this comment.
This seems to be operating on just the BlockData, is there any reason it's on LocationTag and not a MaterialTag property (maybe in MaterialTag.mode)?
| else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_21)) { | ||
| if (getBlockData() instanceof CreakingHeart creakingHeart) { | ||
| return new ElementTag(creakingHeart.getCreakingHeartState()); | ||
| } | ||
| } |
There was a problem hiding this comment.
I'd follow what we usually do, just put it as an else if on the main if & in-line the version and material checks as there's only one material.
| else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_21)) { | ||
| if (getBlockData() instanceof CreakingHeart creakingHeart) { | ||
| if (mechanism.requireEnum(CreakingHeart.State.class)) { | ||
| creakingHeart.setCreakingHeartState(value.asEnum(CreakingHeart.State.class)); | ||
| } | ||
| } | ||
| } |
| getTripwire().setDisarmed(CoreUtilities.equalsIgnoreCase(mechanism.getValue().asString(), "disarmed")); | ||
| } | ||
| else if (getBlockData() instanceof Tripwire tripwire) { | ||
| tripwire.setDisarmed(CoreUtilities.equalsIgnoreCase(value.toString(), "disarmed")); |
There was a problem hiding this comment.
You switched these from #asString (generally preferred) to #toString - but in this case it would probably be cleaner to replace this with #asLowerString + just a normal equals?
Adds in the
heart_statetag and mechanism to control a creaking heart's state.Requested in https://discord.com/channels/315163488085475337/1429656035865530380